function testf5(infile, k, msg, outfile)
  % TESTF5  test F5 implemention.
  % usage:
  % TESTF5(INFILE, K, MSG, OUTFILE) : Embed message into OUTFILE.
  % TESTF5(INFILE, K) : Extract message from INFILE.
  
  img = jpeg_read(infile);
  if nargin == 2
      %f5d_simple(img.coef_arrays{1}, k);
      f5d(img.coef_arrays{1}, k);
  else
      if nargin < 4
          outfile = [infile(1:end-3) 'f5.jpg'];
      end
      %[ret, count] = f5e_simple(img.coef_arrays{1}, k, msg);
      [ret, count] = f5e_fix(img.coef_arrays{1}, k, msg);
      img.coef_arrays{1} = ret;
      jpeg_write(img, outfile);
  end
end
